<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>背景资源管理</title>
	<meta name="decorator" content="default"/>

	<script src="${ctxStatic}/colorpick/jQueryColorPicker.min.js" type="text/javascript"></script>
	<script src="${ctxStatic}/colorpick/jqColor.js" type="text/javascript"></script>

	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('<spring:message code="common.subbmiting"/>');
                    timeVali($("#btnSubmit"));
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			var $myColorPicker = $("input[name='color']").colorPicker({
                customBG: '${eleSourceBackground.color}',
                memoryColors:memoryColors,
                size: 3,
                readOnly: true,
                init: function(elm, colors) {
                    elm.style.backgroundColor = setBackgroundColor(elm.value);
                    elm.style.color = colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd';
                },
                displayCallback: function(colors, mode, options) {
                    setInputColor($(options.input), colors);
                }
            });

			/*$("input[name='color']").colpick({
				layout:'hex',
				submit:0,
				colorScheme:'dark',
				color:'${eleSourceBackground.color}',
				onChange:function(hsb,hex,rgb,el,bySetColor) {
					$(el).css('border-color','#'+hex);
					if(!bySetColor){
						$(el).val('#'+hex);
					}
				}
			}).keyup(function(){
				$(this).colpickSetColor(this.value);
			});*/
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/source/background/eleSourceBackground/">
			<spring:message code="background.list"/>
		</a>
		</li>
		<li class="active">
			<a href="${ctx}/source/background/eleSourceBackground/form?id=${eleSourceBackground.id}">
				<shiro:hasPermission name="source:background:eleSourceBackground:edit">
					<c:if test="${not empty eleSourceBackground.id}">
						<spring:message code="background.modify"/>
					</c:if>
					<c:if test="${empty eleSourceBackground.id}">
						<spring:message code="background.add"/>
					</c:if>
			</shiro:hasPermission>
				<shiro:lacksPermission name="source:background:eleSourceBackground:edit">
					<spring:message code="background.info"/>
				</shiro:lacksPermission>
			</a>
		</li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="eleSourceBackground" action="${ctx}/source/background/eleSourceBackground/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label"><spring:message code="common.dname"/>：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="25" class="input-large required"/>
												<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><spring:message code='background.color'/>：</label>
			<div class="controls">
				<form:input path="color" htmlEscape="false" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><spring:message code='source.background.picture'/>：</label>
			<div class="controls">
				<form:hidden id="bgImage" path="bgImage" htmlEscape="false" maxlength="255" class="input-large"/>
				<sys:ckfinder input="bgImage" type="images" uploadPath="/source/background/eleSourceBackground" selectMultiple="false"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><spring:message code='source.background.gif'/>：</label>
			<div class="controls">
				<form:hidden id="bgGif" path="bgGif" htmlEscape="false" maxlength="255" class="input-large"/>
				<sys:ckfinder input="bgGif" type="gifs" uploadPath="/source/background/eleSourceBackground" selectMultiple="false"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><spring:message code='common.remarks'/>：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="source:background:eleSourceBackground:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="<spring:message code='common.save'/>"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="<spring:message code='common.back'/>" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>